import ctypes
import os
import platform


def get_free_space_mb(folder):
    """ Return folder/drive free space (in bytes)
    """
    gb = 1024 * 1024 * 1024
    if platform.system() == 'Windows':
        free_bytes = ctypes.c_ulonglong(0)
        ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(folder), None, None, ctypes.pointer(free_bytes))
        return free_bytes.value / 1024 / 1024 / 1024
    else:
        st = os.statvfs(folder)
        print(st.f_bfree * st.f_frsize / gb)
        print(st.f_blocks * st.f_frsize / gb)
        return st.f_bavail * st.f_frsize / gb


print(get_free_space_mb('/'), 'GB')
